package com.zyx.hadoopdemo.lrumap;

import org.apache.hadoop.yarn.util.LRUCacheHashMap;

/**
 * @author Yaxi.Zhang
 * @since 2021/7/1 14:59
 * desc: LruCacheHashMap案例
 */
public class LruCacheHashMapDemo {
    public static void main(String[] args) {
        /*
            构造方法中可以传两个参数
                maxSize: 缓存的最大个数
                accessOrder: true表示按照访问顺序删除过时数据, false表示按照插入顺序删除过期数据
         */
        LRUCacheHashMap<Long, String> lruCacheHashMap = new LRUCacheHashMap<>(3, false);
        lruCacheHashMap.put(1L, "zhangsan");
        lruCacheHashMap.put(2L, "lisi");
        lruCacheHashMap.put(3L, "wangwu");
        lruCacheHashMap.get(1L);
        lruCacheHashMap.put(4L, "zhaoliu");
        lruCacheHashMap.put(5L, "tianqi");

        System.out.println(lruCacheHashMap);
    }
}
